How to Add the Content Containers Module

About

  • Content Containers is a SmartHub module located in the modules directory - <SmartHub_root>\modules

  • SmartHub Content Containers replaces the Content-By-Search feature.

    • Note: Content-By-Search code is still supported.
      Any existing CBS structure will continue to function.

  • Supported templates are HTML (underscore)

Content Containers:

  • Can be rendered event-based, anywhere on the page

  • A single SmartHub page can contain multiple Content Containers

  • Configuration is based on the standard settings files (Index/Results.js settings files).

  • Modifying HTML pages (Results.html/Index.html) is unnecessary.

How to Configure the Content Containers Module

The Content Containers features is configured by modifying the custom settings file for your page.

Take the appropriate settings from the DefaultModuleSettings.js file (modules\SmartHubResourceLoader\DefaultModuleSettings.js), and copy them into your custom settings file.

Use /modules/SmartHubResourceLoader/CustomSettingsTemplate.js as a template to create your custom settings file.

Note: Custom pages and their associated settings files are described in detail in How to Customize Your SmartHub User Interface.

Note: Do not modify DefaultModuleSettings.js.

Copy Content Container settings from the file (as shown in the example below) to your page's settings file and modify the settings as desired.

DefaultModuleSettings.js is overwritten at upgrade time.

Content Containers Settings Example

Copy
SH.ContentContainers.CustomSettings = {
    ContentContainers: {
        SampleCBSWithDefaultValues: {
            ParentContainerSelector: '.sh-main-results-container',
            Title: '',
            ControlTemplatePath: SH.RootLevelURL + "/modules/ContentContainers/templates/cbsControlTemplate.html",
            ItemTemplatePicker: function (result) { return SH.RootLevelURL + "/modules/ContentContainers/templates/cbsItemTemplate.html"; },
            QueryTemplate: '{searchboxquery} FederatorBackends:"*"',
            SourceId: 'b29924a9-ec32-4c10-8892-a544b69ee121',
            RowsPerPage: 5,
            EnablePagination: false,
            EnableCountTotal: false,
            EnableSmartPreviews: true,
            EnableContentIntelligence: true,
            EnableResultFeedback: true,
            EnableRatings: false,
            EnablePubChemViewer: false,
            Baskets: { '.basketButton': true },
            ShowSort: false,
            SortProperties: 'Rank,Date',
            SortDirection: 'Descending,Ascending',
            IsMainResults: false,
            FieldsToInclude: 'clickUri,title,Rank,ContentSource,FileExtension,excerpt,SDFUrl,date,DisplayAuthor,isUserProfile,WorkEmail,Title,JobTitle,Department,AboutMe,escbasecrawurl,UserName',
            TriggerNewQueryOn: 'afterInitialization',
            DefferredRendering: false
        }  
    }
};
SH.ContentContainers.PathsToExclude = [];

Content Containers Parameters

Setting Name Default Value Description
PreviousLabel "Previous" The tool-tip of the "Previous" button.
NextLabel "Next" The tool-tip of the "Next" button.
SortLabel "Sort by: " The text displayed in the sort section.
CollapseLabel "Collapse" The tool-tip of the "Collapse" button.
ExpandLabel "Expand" The tool-tip of the "Expand" button.
CloseLabel "Close" The tool-tip of the "Close" button.
NoResultsLabel "Sorry, no results found!" The message displayed when there are no results for the performed search.
UserProfileServiceURL SH.RootLevelURL + "/Services/UserProfileService.svc" The URL for the user profile service (required for Analytics).
ContentContainers List of Content Containers
Copy
SampleCBSWithDefaultValues: {
                    ParentContainerSelector: '.sh-main-results-container',
                    Title: '',
                    ControlTemplatePath: SH.RootLevelURL + "/modules/ContentContainers/templates/cbsControlTemplate.html",
                    ItemTemplatePicker: function (result) { return SH.RootLevelURL + "/modules/ContentContainers/templates/cbsItemTemplate.html"; },
                    QueryTemplate: '{searchboxquery} FederatorBackends:"*"',
                    SourceId: 'b29924a9-ec32-4c10-8892-a544b69ee121',
                    RowsPerPage: 5,
                    EnablePagination: false,
                    EnableCountTotal: false,
                    EnableSmartPreviews: true,
                    EnableContentIntelligence: true,
                    EnableResultFeedback: true,
                    EnableRatings: false,
                    EnablePubChemViewer: false,
                    Baskets:{'.basketButton':false},
                    ShowSort: false,
                    AllowUserActivation: true,
                    SortProperties: 'Rank,Date',
                    SortDirection: 'Descending,Ascending',
                    IsMainResults: false,
                    FieldsToInclude: 'clickUri,title,Rank,ContentSource,FileExtension,excerpt,SDFUrl,date,DisplayAuthor,isUserProfile,WorkEmail,Title,JobTitle,Department,AboutMe,escbasecrawurl,UserName',
                    TriggerNewQueryOn: 'afterInitialization'
                    DeferredRendering: false

},
SampleMainResultsWithDefaultValues: {
                    ParentContainerSelector: '.sh-main-results-container',
                    Title: '',
                    ControlTemplatePath: SH.RootLevelURL + "/modules/ContentContainers/templates/controlResultTemplate.html",
                    ItemTemplatePicker: function (result) {
                        if (result.isError)
                            return SH.RootLevelURL + "/modules/ContentContainers/templates/errorResultItemTemplate.html";
                        if (result.isUserProfile == 'true')
                            return SH.RootLevelURL + "/modules/ContentContainers/templates/peopleResultItemTemplate.html";
                        if(result.isAuth)
                            return SH.RootLevelURL + "/modules/ContentContainers/templates/authResultItemTemplate.html";
    
                        return SH.RootLevelURL + "/modules/ContentContainers/templates/resultItemTemplate.html";
                    },
                    QueryTemplate: '{searchboxquery} FederatorBackends:"*"',
                    SourceId: 'b29924a9-ec32-4c10-8892-a544b69ee121',
                    RowsPerPage: 10,
                    EnablePagination: false,
                    EnableCountTotal: false,
                    EnableSmartPreviews: true,
                    EnableContentIntelligence: true,
                    EnableResultFeedback: true,
                    EnableRatings: false,
                    EnablePubChemViewer: false,
                    Baskets:{'.basketButton':false},
                    ShowSort: false,
                    AllowUserActivation: false,
                    SortProperties: 'Rank,Date',
                    SortDirection: 'Descending,Ascending',
                    FieldsToInclude: 'clickUri,title,Rank,ContentSource,FileExtension,excerpt,SDFUrl,date,DisplayAuthor,isUserProfile,WorkEmail,JobTitle,Department,AboutMe,escbasecrawurl,UserName,PictureUrl',
                    TriggerNewQueryOn: 'deferredQuerySuccess',
                    IsMainResults: true,
                    DeferredRendering: false

}
The list of Content Containers that will be rendered.
 
  • SampleCBSWithDefaultValues

- The content container name is not important, you can name it however you like.
 

ParentContainerSelector

'.sh-main-results-container' The parent selector used for the appending of the compiled template of the container.
  Title 'Content Container' The displayed name for the content container.
  ControlTemplatePath SH.RootLevelURL + "/modules/ContentContainers/templates/cbsControlTemplate.html" Content Container template path. You can customize the template and provide the path to the custom template using this parameter.
  ItemTemplatePicker function (result) { return SH.RootLevelURL + "/modules/ContentContainers/templates/cbsItemTemplate.html"; } The function which allows choosing which template to load based on the item metadata.
  QueryTemplate '{searchboxquery} FederatorBackends:"*"' The query template to use when executing the query.
  SourceId 'b29924a9-ec32-4c10-8892-a544b69ee121' The query results source id to use when executing the query. If it is left empty the current tab id is used.
  FieldsToInclude 'clickUri,title,Rank,ContentSource,FileExtension,excerpt,SDFUrl,date,DisplayAuthor,isUserProfile,WorkEmail,Title,JobTitle,Department,AboutMe,escbasecrawurl,UserName' These are query.SelectedProperties requested with each search query.
  RowsPerPage 5 The number of items to request when executing the query.
  EnablePagination false

true - pagination control is displayed on the container.

false - pagination control is hidden.

  EnableSmartPreviews true

true - SmartPreviews functionality is enabled. The items will support showing a binoculars icon which shows the SmartPreviews Viewer when clicked on.

false - SmartPreviews functionality is disabled.

  ShowSort false

true - sort control is displayed on the container.

false - sort control is hidden.

  AllowUserActivation true

true - container shows in the "My homepage" section and can be disabled or enabled by the user.

false - user cannot choose to enabled or disabled the container. Container will be visible by default

  SortProperties 'Rank,Date' The properties available for sorting. This needs to be sortable properties in the search engine. The first property in the SortProperties list will be used as the default sort property.
  SortDirection 'Descending,Ascending' The sort mode to use with the specified SortProperty. Possible values are “Ascending” and “Descending”. First value in the list will be used as the default one.
  TriggerNewQueryOn 'afterInitialization'

The event name which when fired, a new query will be executed and the results rendered. If left empty, then the Container will only render after being invoked via API.

Examples of events: afterInitialization, deferredQuerySuccess or any custom event.

  EnableCountTotal false true - the total count is displayed on the container. false - the total count is hidden.
  EnableContentIntelligence true

true - ContentIntelligence functionality is enabled. The items will support showing an info icon which shows a modal with details of the result when clicked on.

false -ContentIntelligence functionality is disabled.

  EnableResultFeedback true

true - ResultFeedback functionality is enabled. The items will support showing a feedback icon which shows a feedback form when clicked on.

false - ResultFeedback functionality is disabled.

  EnableRatings false

true - Ratings functionality is enabled. The ratings of the results will be displayed.

false - Ratings functionality is disabled.

  EnablePubChemViewer false true - PubChemViewer functionality is enabled. The items will support showing a button labeled "3D Model" which shows the PubChem Viewer when clicked on. false - PubChemViewer functionality is disabled.
  Baskets {'.basketButton':false} true - Baskets functionality is enabled. The items will support showing a button labeled "Add to basket/Remove from basket" which adds/removes the item to/from the basket when clicked on. false - Baskets functionality is disabled.
  IsMainResults false

true - The content container contains the main results.

false - The content container doesn't contain the main results and behaves like a normal CBS.

  DeferredRendering false

true - The ContentContainer will not render the results, instead it will trigger an event named "ContentContainerDeferredRendering". This event will contain the information about the container Id, container settings and the results, and can be used to handle the result rendering via a custom function.

false - The ContentContainer will use it's internal methods to render the items.